@page "/Admin/Userlist"
@rendermode InteractiveServer
@attribute [Authorize(Roles = "Administrator")]
@attribute [UserNavigation("用户管理")]
@attribute [TabItemOption(Text = "用户管理", Icon = "fa-solid fas fa-user-secret")]
 
<Table TItem="User" 
    ExtendButtonColumnWidth="270" 
    OnQueryAsync="OnQueryAsync"
        IsPagination="true"
        SearchModel="@Users" 
        ShowSearch="true"
        ShowEmpty="true" 
        ShowDeleteButton="false"
        ShowAddButton="true"
        ShowToolbar="true" 
        IsMultipleSelect="true" 
        OnSaveAsync="OnSaveAsync"
         @ref="@UserTable"
         AutoGenerateColumns="true"
    >
    <TableToolbarTemplate>
        <TableToolbarButton TItem="User" IsEnableWhenSelectedOneRow="true" Color="Color.Info" Icon="fa-solid fa-user-shield" Text="分配角色" OnClickCallback="users => OnAssignmentRoles(users.First())" />
 
        <TableToolbarButton TItem="User" IsEnableWhenSelectedOneRow="true" Color="Color.Warning" Icon="fa-solid fa-key" Text="重置密码"  OnClickCallback="users => OnResetPassword(users.First())"/>
        <TableToolbarButton TItem="User" IsEnableWhenSelectedOneRow="true" Color="Color.Danger" Icon="fa-solid fa-lock" Text="锁定帐户"  OnClickCallback="users => OnLockUser(users.First())"/>
        <TableToolbarButton TItem="User" IsEnableWhenSelectedOneRow="true" Color="Color.Secondary" Icon="fa-solid fa-unlock" Text="解锁"  OnClickCallback="users => OnUnlockUser(users.First())"/>
    </TableToolbarTemplate>
    <TableColumns>
        <TableColumn @bind-Field="@context.UserName"   Sortable="true" Filterable="true" Searchable="true"></TableColumn>
        <TableColumn @bind-Field="@context.DisplayName" Sortable="true" Filterable="true" Searchable="true"></TableColumn>
        <TableColumn @bind-Field="@context.RegisterTime" ></TableColumn>
        <TableColumn @bind-Field="@context.ApprovedTime"  ></TableColumn>
        <TableColumn @bind-Field="@context.LockoutEnabled"  Text="是否启用锁定"   ></TableColumn>
        <TableColumn @bind-Field="@context.LockoutEnd"  Text="锁定截至时间"   ></TableColumn>
        <TableColumn @bind-Field="@context.Email" Sortable="true" Filterable="true" Searchable="true"></TableColumn>
        <TableColumn @bind-Field="@context.WeChatId" Sortable="true" Filterable="true" Searchable="true"></TableColumn>
        <TableColumn @bind-Field="@context.PhoneNumber" Sortable="true" Filterable="true" Searchable="true"></TableColumn>
    </TableColumns>
    

    @* <RowButtonTemplate>
        <TableCellButton Size="Size.ExtraSmall" Color="Color.Info" Icon="fa-solid fa-users-gear" Text="分配角色" OnClick="() => OnAssignmentRoles(context)" />
        <TableCellButton Size="Size.ExtraSmall" Color="Color.Info" Icon="fa-solid fa-users-gear" Text="充值" OnClick="() => OnRecharge(context)" />
        <TableCellButton Size="Size.ExtraSmall" Color="Color.Info" Icon="fa-solid fa-users-gear" Text="重置密码" OnClick="() => OnResetPassword(context)" />
    </RowButtonTemplate> *@
</Table>
 